Skip to content

Лебедев Никита#54

Open
nest-aka-swan wants to merge 1 commit intourfu-2016:masterfrom
nest-aka-swan:master
Open

Лебедев Никита#54
nest-aka-swan wants to merge 1 commit intourfu-2016:masterfrom
nest-aka-swan:master

Conversation

@nest-aka-swan
Copy link
Copy Markdown

No description provided.

@honest-hrundel
Copy link
Copy Markdown

🍏 Пройдено тестов 13 из 13

on: function (event, context, handler) {
console.info(event, context, handler);
var times = arguments[3] || Infinity;
var frequency = arguments[4] || 1;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Для отрицательных чисел должно работать просто как метод on

this.events[evt] = this.events[evt].filter(function (listener) {
return listener.context !== context;
});
}.bind(this));
Copy link
Copy Markdown

@ninjagrizzly ninjagrizzly Nov 14, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Функция forEach принимает вторым аргументом контекст, то есть можно писать так
forEach(function (args) {...}, this)

if (listeners) {
listeners
.filter(function (listener) {
return listener.timesCalled !== listener.times;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тут проверяешь на !== и еще внутри функции callHandler проверяется условие this.timesCalled < this.times. Можешь пояснить зачем так?

* @param {String} event
* @returns {Object}
*/
emit: function (event) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Можно удалять события several из общего списка после вызова их n раз

@ninjagrizzly
Copy link
Copy Markdown

🍅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants